/*******************************************************************************
 * Copyright 2011 WaTho
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package de.wathoserver.android.dragoid.api;

import java.util.HashMap;
import java.util.Map;

/**
 * Datensatz mit allen Informationen für einen Gebäudeaus- oder umbau.
 * 
 * @author watho
 * 
 */
public class BuildingUpgrade {

	public static final String COL_NAME = "buildingupgrade_name";
	public static final String COL_REQUIREMENT_BUILDING = "buildingupgrade_requirementbuilding";
	public static final String COL_REQUIREMENT_STOCK = "buildingupgrade_requirementstock";
	public static final String COL_BUILDINGTIME = "buildingupgrade_buildingtime";
	public static final String COL_PRODUCES = "buildingupgrade_produces";
	public static final String COL_MISSINGSTOCK = "buildingupgrade_missingstock";

	// Building.BUILDING_TYPES parentType;
	// Building.BUILDING_TYPES type;
	String name;
	String requirementBuilding;
	String requirementStock;
	String buildingtime;
	String produces;
	String missingStock;
	boolean upgrade;
	boolean prepared;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Vorausgesetzte Gebäudestufe
	 * 
	 * @return
	 */
	public String getRequirementBuilding() {
		return requirementBuilding;
	}

	public void setRequirementBuilding(String requirementBuilding) {
		this.requirementBuilding = requirementBuilding;
	}

	/**
	 * Kostet an Waren
	 * 
	 * @return
	 */
	public String getRequirementStock() {
		return requirementStock;
	}

	public void setRequirementStock(String requirementStock) {
		this.requirementStock = requirementStock;
	}

	/**
	 * Ausbaudauer
	 * 
	 * @return
	 */
	public String getBuildingtime() {
		return buildingtime;
	}

	public void setBuildingtime(String buildingtime) {
		this.buildingtime = buildingtime;
	}

	/**
	 * Produktion der nächsten Stufe
	 * 
	 * @return
	 */
	public String getProduces() {
		return produces;
	}

	public void setProduces(String produces) {
		this.produces = produces;
	}

	/**
	 * Für den Ausbau fehlen noch
	 * 
	 * @return
	 */
	public String getMissingStock() {
		return missingStock;
	}

	public void setMissingStock(String missingStock) {
		this.missingStock = missingStock;
	}

	/**
	 * wahr, wenn es ein Ausbau ist, falsch, wenn es ein Umbau ist
	 * 
	 * @return
	 */
	public boolean isUpgrade() {
		return upgrade;
	}

	public void setUpgrade(boolean upgrade) {
		this.upgrade = upgrade;
	}

	/**
	 * Liefert "Ausbau" oder "Umbau" je nach Typ
	 * 
	 * @return
	 * @see {@link #isUpgrade()}
	 */
	public String getTypeStr() {
		return isUpgrade() ? "Ausbau" : "Umbau";
	}

	/**
	 * Liefert "upgrade" oder "reconstruct" je nach Typ
	 * 
	 * @return
	 * @see {@link #isUpgrade()}
	 */
	public String getActionStr() {
		return isUpgrade() ? "upgrade" : "reconstruct";
	}

	/**
	 * <p>
	 * Wahr, wenn der Aus/Umbau gestartet werden kann.
	 * </p>
	 * Wird im Moment aus html ausgelesen, sollte in Zukunft besser über
	 * benötigte und vorhandene Rohstoffe berechnet werden.
	 * 
	 * @return
	 */
	public boolean isPrepared() {
		return prepared;
	}

	public void setPrepared(boolean prepared) {
		this.prepared = prepared;
	}

	public Map<String, String> toMap() {
		Map<String, String> result = new HashMap<String, String>();
		result.put(COL_NAME, name);
		result.put(COL_BUILDINGTIME, buildingtime);
		result.put(COL_MISSINGSTOCK, missingStock);
		result.put(COL_PRODUCES, produces);
		result.put(COL_REQUIREMENT_BUILDING, requirementBuilding);
		result.put(COL_REQUIREMENT_STOCK,
				String.format("Kostet %s", requirementStock));
		return result;
	}
}
